﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using SuperQuiz.Model;
using Microsoft.Phone.Shell;
using Config;
using System.IO.IsolatedStorage;

namespace SuperQuiz
{
    public partial class SummaryPage : PhoneApplicationPage
    {
        public SummaryPage()
        {
            InitializeComponent();

            Summary summary = (Summary) PhoneApplicationService.Current.State["Summary"];
            
            textTotal.Text = (100 * summary.Right / summary.Total).ToString() + "%";
            textRight.Text = summary.Right.ToString();
            textWrong.Text = summary.Wrong.ToString();

            IsolatedStorageSettings.ApplicationSettings[summary.topicName] = (int) (100 * summary.Right / summary.Total);
            IsolatedStorageSettings.ApplicationSettings.Save();

            Test currentTest = (Test)PhoneApplicationService.Current.State["CurrentTest"];
            currentTest.LastPerfomance = (int)(100 * summary.Right / summary.Total);
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            this.NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
    }
}